/*
 *  $Id: Abominate.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Fire.Spells {
    public class Abominate: TargetEnchantmentCard<Creature> {
        public Abominate(): base("001_f_s_abominate") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Fire;
            Value = 100;
            Target = CreatureTarget.Own;
            AddManaCost(ElementType.Fire, 2);
        }

        private int _dmgBonus;

        protected override void DoAction(TargetArgs<Creature> args) {
            int dmgBonus = 0;
            foreach (Creature cr in args.Player.GetCreatures()) {
                if (cr != args.Target) {
                    dmgBonus += cr.Damage - 1;
                    cr.InstantDeath();
                }
            }
            if (dmgBonus < 0) dmgBonus = 0;
            _dmgBonus = dmgBonus;
            base.DoAction(args);
        }
        protected override EnchantmentAffect CreateEnchantment() {
            return new AbominateAffect(_dmgBonus);
        }

        private class AbominateAffect: EnchantmentAffect<Abominate> {
            private int _bonus;

            public AbominateAffect(int bonus): base(true) {
                DefaultDescription = true;
                _bonus = bonus;
                Add(new Affects.Immortal());
                Add(new Affects.Death(1));
                Add(new Affects.Brutal());
                Add(new Affects.ModDamage(bonus));
            }

            public override string DescriptionText {
                get { return Description.GetText(_bonus); }
            }

            public override bool Dispellable {
                get { return false; }
            }

            public override Affect Clone() {
                return new AbominateAffect(_bonus);
            }
        }
    }
}
